<?php
class ProductDetail_Model_Imagetothing extends Zend_Db_Table{
	protected $_name = 'imagetothing';
	protected $_primary = 'image_id';
	/* Link tham khao : http://framework.zend.com/manual/en/zend.db.table.html */
	/* select demo */
	
	public function getImageByThingsId($thingId)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/imagetothing/route/getImageByThingsId/id/".$thingId);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
				
		return $data;
		
	}
	public function insertImage($data)
	{// co dung
		$data['route'] = "insertImage";
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restPost("/imagetothing", $data);

		return $return->getBody();
	}

	public  function  deletething($id)
	{// co dung	
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restDelete("/imagetothing/route/deletething/id/".$id);
		return $return->getBody();
	}
}
?>